vim.g.mapleader = " "

local keymap = vim.keymap

-- 取消高亮
keymap.set("n", "<leader>nh", ":nohl<CR>")


-- 关于 立刻打开 init.lua
vim.keymap.set("n", "<leader>rc", ":e ~/.config/nvim/init.lua <cr>", opts)




--快速移动贯标
keymap.set("n","J","5j")
--keymap.set("n","K","5k")
keymap.set("n","H","0")
keymap.set("n","L","$")
keymap.set("n","Q",":q!<enter>")

--let g:lightline#bufferline#show_number = 1
--let g:lightline#bufferline#number_separator = '' 

keymap.set("n","<","<<")
keymap.set("n",">",">>")
keymap.set("v","<","<gv")
keymap.set("v",">",">gv")

--关于分屏
keymap.set("n","sj",":set splitbelow<CR>:split<CR>")
keymap.set("n","sl",":set splitright<CR>:vsplit<CR>")


keymap.set("n","<leader>l","<c-w>l")
keymap.set("n","<leader>h","<c-w>h")
keymap.set("n","<leader>k","<c-w>k")
keymap.set("n","<leader>j","<c-w>j")


keymap.set("n","<up>",":res +5<cr>")
keymap.set("n","<down>",":res -5<cr>")
keymap.set("n","<left>",":vertical resize+5<cr>")
keymap.set("n","<right>",":vertical resize-5<cr>")





-- buffer 切换
vim.keymap.set("n", "bh", ":bp<cr>", opts)
vim.keymap.set("n", "bl", ":bn<cr>", opts)

vim.keymap.set("n", "bd", ":bdelete<cr>", opts)
vim.keymap.set("n", "bD", ":bdelete!<cr>", opts)
vim.keymap.set("n", "bd", ":BufferLinePickClose<CR>", opts)



------------------------------------------
--关于treesitter 的折叠

keymap.set("n","<leader>z","zR")
keymap.set("n","<leader>Z","zM")










-- ---------- 插件 ---------- ---
-- nvim-tree
keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>")




--telescope
local builtin = require('telescope.builtin')
keymap.set('n', '<leader>ff', builtin.find_files, {})
keymap.set('n', '<leader>fg', builtin.live_grep, {})
keymap.set('n', '<leader>fb', builtin.buffers, {})
keymap.set('n', '<leader>fh', builtin.help_tags, {})
keymap.set('n', '<leader>fd', builtin.current_buffer_fuzzy_find, {})


--关于 flash.vim 的配置
keymap.set('n', 'S', '<cmd>lua require("flash").jump()<CR>', { desc = 'Flash' })
keymap.set('x', 'S', '<cmd>lua require("flash").jump()<CR>', { desc = 'Flash' })
keymap.set('o', 'S', '<cmd>lua require("flash").jump()<CR>', { desc = 'Flash' })

keymap.set('n', 'D', '<cmd>lua require("flash").treesitter()<CR>', { desc = 'Flash Treesitter' })
keymap.set('o', 'D', '<cmd>lua require("flash").treesitter()<CR>', { desc = 'Flash Treesitter' })
keymap.set('x', 'D', '<cmd>lua require("flash").treesitter()<CR>', { desc = 'Flash Treesitter' })

keymap.set('o', 'r', '<cmd>lua require("flash").remote()<CR>', { desc = 'Remote Flash' })
keymap.set('o', 'R', '<cmd>lua require("flash").treesitter_search()<CR>', { desc = 'Treesitter Search' })

--关于全词匹配
--nnoremap <leader>w /\<<CR>=expand("<cword>")<CR>\><CR>



-- 设置标签文件的路径
vim.o.tags = './tags;'
-- 设置快捷键跳转到定义
vim.api.nvim_set_keymap('n', '<C-]>', ':tag <C-R><C-W><CR>', { noremap = true, silent = true })
--vim.api.nvim_set_keymap('n', '<C-[>', ':poptag<CR>', { noremap = true, silent = true })



--let g:bookmark_highlight_all = 1

-- 设置bookmark
vim.api.nvim_set_keymap('n', '<Leader><Leader>', '<Plug>BookmarkToggle', { noremap = true })
vim.api.nvim_set_keymap('n', '<Leader>a', '<Plug>BookmarkShowAll', { noremap = true })
vim.api.nvim_set_keymap('n', '<Leader>x', '<Plug>BookmarkClearAll', { noremap = true })


























